<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="com.edu.entity.*" %>
<%@ page import="com.edu.service.*" %>
<%@ page import="com.edu.service.Impl.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>车辆调度</title>
	<link rel="stylesheet" href="css/index.css">
</head>
<body>
	<header class="header">
		<div>
			<p><img src="images/xt.jpg" alt="">系统首页</p>
			<ul>
				<li>
					<a href="#" onclick="javascript:show1()">
						<img src="images/gr.jpg" alt="">个人中心<img src="images/xl.jpg" alt="">
					</a>
				</li>
				<li name='zq1'>
					<a href="individual.jsp">个人</a>
				</li>
			</ul>
			<ul>
				<li>
					<a href="#" onclick="javascript:show2()">
						<img src="images/js.jpg" alt="">驾驶员管理<img src="images/xl.jpg" alt="">
					</a>
				</li>
				<li name='zq2'>
					<a href="Driver.jsp">驾驶员</a>
				</li>
			</ul>
			<ul>
				<li>
					<a href="#" onclick="javascript:show3()">
						<img src="images/xx.jpg" alt="">车辆信息管理<img src="images/xl.jpg" alt="">
					</a>
				</li>
				<li name='zq3'>
					<a href="Trucks.jsp">车辆信息</a>
				</li>
			</ul>
			<ul>
				<li>
					<a href="#" onclick="javascript:show4()">
						<img src="images/jd.jpg" alt="">借调车俩管理<img src="images/xl.jpg" alt="">
					</a>
				</li>
					<li name='zq4'>
				<a href="Tcheck.jsp">借调车俩</a>
				</li>
			</ul>
			<ul>
				<li>
					<a href="#" onclick="javascript:show5()">
						<img src="images/jd.jpg" alt="">车俩调度管理<img src="images/xl.jpg" alt="">
					</a>
				</li>
				<li name='zq5'>
					<a href="Dispatch.jsp">车俩调度</a>
				</li>
			</ul>
			<ul>
				<li>
					<a href="#" onclick="javascript:show6()">
						<img src="images/cl.jpg" alt="">车俩运营管理<img src="images/xl.jpg" alt="">
					</a>
				</li>
				<li name='zq6'>
					<a href="Trun.jsp">车俩花销</a>
				</li>
			</ul>
			<ul>
				<li>
					<a href="#" onclick="javascript:show7()">
						<img src="images/js.jpg" alt="">驾驶员运营管理<img src="images/xl.jpg" alt="">
					</a>
				</li>
				<li>
					<a href="#" onclick="javascript:show7()">
						<img src="images/js.jpg" alt="">驾驶员管理<img src="images/xl.jpg" alt="">
					</a>
				</li>
				<li name='zq7'>
					<a href="Drun.jsp">驾驶员花销</a>
				</li>
			</ul>
		</div>
	</header>
	<footer class="footer">
		<div class="sm">
			<h3>货车调度管理系统</h3>
		</div>
		<ul>
			<li>
				管理员:&nbsp;&nbsp;${user.username }
			</li>
			<li>
				<a href="page.jsp">退出登录</a>
			</li>
		</ul>
	</footer>
	<section class="section">
		<form id="dispatchForm" action="DispatchDeleteServlet" method="post"> 
		   <div>
	  			<p>系统首页&nbsp;>&nbsp;车辆调度管理</p>
		  		<div id="xs">
					序&nbsp;号
					<input class="form-input" type="text" name="dispatchId" id="dispatchId">&nbsp;
					派车&nbsp;编号
					<input class="form-input" type="text" name="tNum" id="tNum">&nbsp;
					出发&nbsp;时间
					<input class="form-input" type="text" name="dTrigger" id="dTrigger">&nbsp;
					<br><br>
					到达&nbsp;时间
					<input class="form-input" type="text" name="dReach" id="dReach">&nbsp;
					出发&nbsp;地点
					<input class="form-input" type="text" name="dDepart" id="dDepart">&nbsp;
					目的&nbsp;地点
					<input class="form-input" type="text" name="dPurpose" id="dPurpose">&nbsp;
					<br><br>
					回程&nbsp;时间
					<input class="form-input" type="text" name="dReturn" id="dReturn">&nbsp;
					驾驶员&nbsp;工号
					<input class="form-input" type="text" name="dJob" id="dJob">&nbsp;
					驾驶员&nbsp;姓名
					<input class="form-input" type="text" name="dName" id="dName">&nbsp;
					<br><br>
					联系&nbsp;方式
					<input class="form-input" type="text" name="dPhone" id="dPhone">&nbsp;
					<br><br>
					<br>
		    		<input class="form-input2" type="button" onclick="changeAction('DispatchServlet?menu=1')"  value="查询">&nbsp;&nbsp;
					<input class="form-input2" type="button" onclick="changeAction('DispatchServlet?menu=3')" value="添加">&nbsp;&nbsp;
					<input class="form-input2" type="button" onclick="changeAction('DispatchServlet?menu=4')" value="删除">&nbsp;&nbsp;
					<input class="form-input2" type="button" onclick="changeAction('DispatchServlet?menu=2')" value="修改">&nbsp;&nbsp;
					<input class="form-input2" type="reset" >
				</div>
			</div>
		    <table class="d-table">
	  			<tr>
	  				<td>全选</td>
	  				<td>索引</td>
	  				<td>派车编号</td>
	  				<td>出发时间</td>
	  				<td>到达时间</td>
	  				<td>出发地点</td>
	  				<td>目的地点</td>
	  			    <td>回程时间</td>
	  				<td>驾驶员工号</td>
	  				<td>驾驶员姓名</td>
	  				<td>联系方式</td>
	  				<td>操作</td>
	  			</tr>
	  			<%	
	  			
	  				Object obj = request.getAttribute("list");
	  				List<Dispatch> list = new ArrayList<Dispatch>(); 
	  				if(obj != null){
	  					list = (List<Dispatch>)obj;
	  				}else{
	  					DispatchService dispatchService = new DispatchServiceImpl();
		  				list = dispatchService.showDispatchList();
	  				}
	  				for(int i=0; i<list.size(); i++){
	  					Dispatch dispatch = list.get(i);
	  				
	  			%>
	  			<tr>
	  				<td><input type="checkbox" name="selectdispatchId" value="<%=dispatch.getDispatchId() %>"/></td>
	  				<td><%=dispatch.getDispatchId() %></td>
	  				<td><%=dispatch.gettNum() %></td>
	  				<td><%=dispatch.getdTrigger() %></td>
	  				<td><%=dispatch.getdReach() %></td>
	  				<td><%=dispatch.getdDepart() %></td>
	  				<td><%=dispatch.getdPurpose() %></td>
	  				<td><%=dispatch.getdReturn() %></td>
	  				<td><%=dispatch.getdJob() %></td>
	  				<td><%=dispatch.getdName() %></td>
	  				<td><%=dispatch.getdPhone() %></td>
	  				<td>
		  				<input type="button" value="删除" onclick="mysubmit(<%=dispatch.getDispatchId() %>)"/>
		  				<input type="button" onclick="show('<%=dispatch.getDispatchId() %>','<%=dispatch.gettNum() %>','<%=dispatch.getdTrigger() %>','<%=dispatch.getdReach() %>','<%=dispatch.getdDepart() %>','<%=dispatch.getdPurpose() %>','<%=dispatch.getdReturn() %>','<%=dispatch.getdJob() %>','<%=dispatch.getdName() %>','<%=dispatch.getdPhone() %>')" value="查看"/>
		  			</td>
	  			</tr>
	  			<%
	  				}
	  			%>
	  		</table> 
	  		<input id="uid" type="hidden" value="" name="uid"/>
	  	</form>
	</section>
</body>
<script>
	function show1(){
		var obj=document.getElementsByName('zq1');
		for(var i=0;i<obj.length;i++){
			var a=obj[i].style.display;
			if(a == 'block'){
				obj[i].style.display='none';
			}else{
				obj[i].style.display='block';
			}
		}
	}
	
	function show2(){
		var obj=document.getElementsByName('zq2');
		for(var i=0;i<obj.length;i++){
			var a=obj[i].style.display;
			if(a == 'block'){
				obj[i].style.display='none';
			}else{
				obj[i].style.display='block';
			}
		}
	}
	
	function show3(){
		var obj=document.getElementsByName('zq3');
		for(var i=0;i<obj.length;i++){
			var a=obj[i].style.display;
			if(a == 'block'){
				obj[i].style.display='none';
			}else{
				obj[i].style.display='block';
			}
		}
	}
	
	function show4(){
		var obj=document.getElementsByName('zq4');
		for(var i=0;i<obj.length;i++){
			var a=obj[i].style.display;
			if(a == 'block'){
				obj[i].style.display='none';
			}else{
				obj[i].style.display='block';
			}
		}
	}
	
	function show5(){
		var obj=document.getElementsByName('zq5');
		for(var i=0;i<obj.length;i++){
			var a=obj[i].style.display;
			if(a == 'block'){
				obj[i].style.display='none';
			}else{
				obj[i].style.display='block';
			}
		}
	}
	
	function show6(){
		var obj=document.getElementsByName('zq6');
		for(var i=0;i<obj.length;i++){
			var a=obj[i].style.display;
			if(a == 'block'){
				obj[i].style.display='none';
			}else{
				obj[i].style.display='block';
			}
		}
	}
	
	function show7(){
		var obj=document.getElementsByName('zq7');
		for(var i=0;i<obj.length;i++){
			var a=obj[i].style.display;
			if(a == 'block'){
				obj[i].style.display='none';
			}else{
				obj[i].style.display='block';
			}
		}
	}
	
	function $(id){
  		return document.getElementById(id);
  	}
  	
	function mysubmit(uid) {
		$("uid").value=uid;
		var result = confirm("确认删除，删除后将无法修改");
		if (result) {
			$("dispatchForm").submit();
		}
	}
	
	function changeAction(url){
  		$("dispatchForm").action=url;
  		$("dispatchForm").submit();
  	}
  	
  	function show(a,b,c,d,e,f,g,h,i,j){
  		$("dispatchId").value=a;
  		$("tNum").value=b;
  		$("dTrigger").value=c;
  		$("dReach").value=d;
  		$("dDepart").value=e;
  		$("dPurpose").value=f;
  		$("dReturn").value=g;
  		$("dJob").value=h;
  		$("dName").value=i;
  		$("dPhone").value=j;
  	}
</script>
</html>